(deftemplate persoana
    (multislot nume)
    (slot ochi)
    (slot par)
    (slot nationalitate)
)

(assert (persoana (nume Maurice Pierre) (ochi verde) (par saten) (nationalitate francez)))
(assert (persoana (nume Schultz Oliver) (ochi albastru) (par saten) (nationalitate german)))
(assert (persoana (nume Ion Ion) (ochi caprui) (par saten) (nationalitate roman)))
(assert (persoana (nume Cristina Maria) (ochi negru) (par blond) (nationalitate roman)))

(defrule rule1
    (persoana (nume $? ?n ?p) (ochi verde) (par saten) (nationalitate francez))
    =>
    (printout t "Persoana franceza cu ochii verzi si parul saten este " ?n " " ?p "."crlf)
)

(defrule rule2
    (persoana (nume $? ?n ?p) (par ?cp&~negru) (ochi ?co&~albastru)) ;pattern
    (not (persoana (nume $? ?n1&~?n ?p1&~?p) (ochi ?co))) ;antipattern
    (not (persoana (nume $? ?n2&~?n ?p2&~?p) (par ?cp)))
    =>
    (printout t "Persoana " ?n " " ?p " este persoana unica cautata." crlf)
)

(defrule rule3
    (persoana (nume $? ?n ?p) (par ?cp&~blond) (ochi ?co) (nationalitate german))
    (test (or (eq ?cp saten) (eq ?co albastru)))
    (persoana (nume $? ?n1&~?n ?p1&~?p) (par ?cp) (ochi ?co2&verde))
    (test (or (not (eq ?cp saten)) (eq ?co2 caprui)))
    =>
    (printout t "Persoana 1 este " ?n " " ?p crlf)
    (printout t "Persoana 2 este " ?n1 " " ?p1 crlf)
)

(agenda)
(run)
